package ModelLayer;

/**
 * Write a description of class PartOrder here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class PartOrder
{
    private Item item;
    private int quantity;
    private double discount;

    /**
     * Constructor for objects of class PartOrder.
     * @param item, the item on this partorder.
     * @param quantity, the quantity of the item on this partorder.
     * @param discount, the discount on this partorder.
     */
    public PartOrder(Item item, int quantity, double discount)
    {
        this.item = item;
        this.quantity = quantity;
        this.discount = discount;
    }

    /**
     * Returns the quantity of items on this partorder.
     * @return quantity, the quantity of the item returned.
     */
    public int getQuantity()
    {
        return quantity;
    }

    /**
     * Returns the total on this partorder including calculated discount.
     * @return (item.getRetailPrice() * quantity) - (discountInMoneyPartOrder + discountInMoneyItem), the total returned.
     */
    public double getPrice()
    {
        double discountInMoneyPartOrder = (item.getRetailPrice() * quantity) / 100 * discount;
        double discountInMoneyItem = (item.getRetailPrice() * quantity) / 100 * item.getDiscount();
        return (item.getRetailPrice() * quantity) - (discountInMoneyPartOrder + discountInMoneyItem); 
    }

    /**
     * Returns the discount on this order.
     * @return discount, the discount on this order returned.
     */
    public double getDiscount()
    {
        return discount;
    }

    /**
     * Returns the total discount in actual money on this partorder.
     * @return discountInMoneyPartOrder + discountInMoneyItem, the total discount on this partorder returned.
     */
    public double getDiscountInMoney()
    {
        double discountInMoneyPartOrder = (item.getRetailPrice() * quantity) / 100 * discount;
        double discountInMoneyItem = (item.getRetailPrice() * quantity) / 100 * item.getDiscount();
        return discountInMoneyPartOrder + discountInMoneyItem;
    }

    /**
     * Returns the name of the item on this partorder.
     * @return item.getItemName(), the name of the item on this partorder returned.
     */
    public String getItemName()
    {
        return item.getItemName();
    }

    /**
     * Sets the quantity of the item on this partorder.
     * @param quantity, the quantity to be set on this partorder.
     */
    public void setQuantity(int quantity)
    {
        this.quantity = quantity;
    }

    /**
     * Sets the discount on this order.
     * @param discount, the discount to be set on this order.
     */
    public void setDiscount(double discount)
    {
        this.discount = discount;
    }

    /**
     * Downsizes the inventory for the quantity of the item on this partorder.
     * @param quantity, the quantity that the inventory will be downsized with.
     */
    public void downsizeInventory()
    {
        item.downsizeInventory(quantity);
    }
    
    public Item getItem()
    {
    	return item;
    }

}
